<!DOCTYPE html>
<html>
<head>
    <title>server_3</title>
</head>
<body>
    <h1>Web安全与防护技术——实验二：浏览器安全</h1>
        <h2>
            当前路径：<span id="cururl"></span>
        </h2>
    <hr>
    <h1>跨域AJAX请求</h1>
    <button style="padding: 8px;margin: 10px;" onclick="makeRequest()">发送请求</button>

    <script>
        document.getElementById('cururl').innerHTML = window.location.href;
        function makeRequest() {
            // 尝试向另一个域发送请求
            fetch('http://www.websecurity.com/data')
                .then(response => response.json())
                .then(data => {
                    console.log('数据：', data);
                })
                .catch(error => {
                    console.error('同源策略阻止：', error);
                });
        }
    </script>
</body>
</html>